from django.db import models
from utils.basemodel import BaseModel
# Create your models here.


class CateModel(models.Model):
    name=models.CharField(max_length=20,verbose_name='名称')
    class Meta:
        db_table='Cate'

class CategoryModel(models.Model):
    bname=models.CharField(max_length=20)
    cate=models.ForeignKey(CateModel,on_delete=models.CASCADE)
    class Meta:
        db_table='Category'
class CakeModel(BaseModel):
    title=models.CharField(max_length=20,verbose_name="名称")
    cover=models.ImageField(upload_to="uploads/",blank=True,null=True)
    tro=models.CharField(max_length=30,verbose_name="介绍")
    cate=models.ForeignKey(CateModel,on_delete=models.CASCADE)
    category=models.ForeignKey(CategoryModel,on_delete=models.CASCADE)
    weight=models.IntegerField(verbose_name="重量(磅)")
    price=models.IntegerField(verbose_name="单价")
    class Meta:
        db_table='Cake'

class CakeDemil(BaseModel):
    cake=models.ForeignKey(CakeModel,on_delete=models.CASCADE)
    img=models.ImageField(upload_to="uploads/",blank=True,null=True)
    intro=models.CharField(max_length=100,verbose_name="详情介绍")
    fw=models.CharField(max_length=10)
    kg=models.CharField(max_length=10)
    kw=models.CharField(max_length=10)
    tj=models.CharField(max_length=20)

class BannerModel(BaseModel):
    title = models.CharField(max_length=50, verbose_name='标题')
    imgsrc = models.ImageField(upload_to='uploads', verbose_name='图片')
    link = models.CharField(max_length=200, verbose_name='链接', default='#')
    ishttp = models.BooleanField(default=False, verbose_name='是否是http链接')

    class Meta:
        db_table='banner'
    def __str__(self):
        return self.title